using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MAPDavy.Entities;

namespace MAPDavy.Repository.Mapping
{
	public class TestMap : EntityTypeConfiguration<Test>
	{
		public TestMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.NameTest)
				.IsRequired()
				.HasMaxLength(100);
				
			this.Property(t => t.Description)
				.HasMaxLength(250);
				
			// Table & Column Mappings
			this.ToTable("Test");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.NameTest).HasColumnName("NameTest");
			this.Property(t => t.Description).HasColumnName("Description");
			this.Property(t => t.SubjectId).HasColumnName("SubjectId");

			// Relationships
			this.HasRequired(t => t.Subject)
				.WithMany(t => t.Tests)
				.HasForeignKey(d => d.SubjectId);
				
		}
	}
}

